#ifndef DEFAULTMANAGER_H
#define DEFAULTMANAGER_H


#if defined (_WIN32)
	#pragma once
#endif

#include <LDF/LargeDisplayManager.h>

#include "ToolkitLayer.h"


//class LargeDisplayManager;
class QuadStrategy;
class ColorMixerStrategy;

/**
 * This is a subclass of LargeDisplayManager and provides a default
 * implementation of the Manager using OpenGL. It also has some auxiliary
 * functions.
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since July 11, 2007
 */
class TOOLKITLAYER_API DefaultManager : public LargeDisplayManager
{
	// Atributes
private:

	
	// Methods
public:
	DefaultManager(FrameTimer* timer = NULL);
	~DefaultManager(void);

	/**
	 * Renders additional information on top of the application canvas.
	 *
	 * @param canvasWidth the width of the screen.
	 * @param canvasHeight the height of the screen.
	 */
	void renderInfo(unsigned int canvasWidth, unsigned int canvasHeight);

	/**
	 * Resizes the display. Here, it only forwards the resizing to the root
	 * component. More specific actions should be taken by the subclasses.
	 *
	 * @param width the new width of the display.
	 * @param height the new height of the display.
	 */
	virtual void resize(unsigned int width, unsigned int height);

	/**
	 * Returns a pseudo-random float value inside the given interval.
	 *
	 * @param max the maximum value of the random value.
	 * @param min the minimum value of the random value.
	 * @return a pseudo-random value in the interval [min, max].
	 */
	inline static float obtainRandomFloat(float max = 1.0f, float min = 0.0f) {
		return float(rand()) / float(RAND_MAX) * (max - min) + min;
	}

	/**
	 * Returns a pseudo-random double value inside the given interval.
	 *
	 * @param max the maximum value of the random value.
	 * @param min the minimum value of the random value.
	 * @return a pseudo-random value in the interval [min, max].
	 */
	inline static double obtainRandomDouble(double max = 1.0, double min = 0.0) {
		return double(rand()) / double(RAND_MAX) * (max - min) + min;
	}



	// DEBUGGING
	/**
	 * Prints the components in this manager.
	 */
	void print();

protected:
	/**
	 * Initializes the component collection by creating and adding application
	 * specific components.
	 */
	virtual void initComponents() {};
	/**
	 * Initializes the list of touch indicators.
	 */
	void initTouchIndicators();
	/**
	 * Returns the id of the component at the given coordinates or zero if no
	 * component was picked.
	 *
	 * @param x the x-coordinate of the selection.
	 * @param y the y-coordinate of the selection.
	 * @return the id of the selected component or zero if none was picked.
	 */
	unsigned long pickComponent(unsigned int x, unsigned int y);
	/**
	 * Returns the id of the container component (i. e., a component that is
	 * not a leaf in the composition tree) at the given coordinates or zero if
	 * no component was picked.
	 *
	 * @param x the x-coordinate of the selection.
	 * @param y the y-coordinate of the selection.
	 * @param excludeComponentId the id of the component that should be
	 * excluded from the picking domain.
	 * @return the id of the selected container component or zero if none was
	 * picked.
	 */
	unsigned long pickContainer(unsigned int x, unsigned int y, unsigned long excludeComponentId);
	

//private:
	/**
	 * Renders a string of characters given a 3D position and a string object.
	 * It makes use of GLUT.
	 *
	 * @param x the x-coordinate where the text is to be written.
	 * @param y the y-coordinate where the text is to be written.
	 * @param z the z-coordinate where the text is to be written.
	 * @param str the string with the text that is to be written.
	 */
	void renderText(float x, float y, float z, const std::string& str);
};

#endif // DEFAULTMANAGER_H
